﻿@using KRM.Core
@model List<KRM.Core.tblLoad>
<script>
    $(document).ready(function() {
        $(".loadunplannedload").dataTable({
            "iDisplayLength": 10000,
            "sScrollY": $(".loadunplannedload").attr("data-height"),
            "sScrollX": "100%",
            "aaSorting": []
        });
        $('.dataTables_paginate').remove();
        $(".tbl-selected tbody tr").click(function () {
            $(this).addClass("row-selected");
            $(this).parent().find("tr").not(this).removeClass('row-selected');
        });
    });
    function removeload(loadid) {
        App.blockUI($('.dgvUnplannedLoads'), false);
        $.ajax({            
            url: "/load/removeload?loadid=" + loadid,
            success:function(data) {
                if (data == "1") {
                    alert("Selected load is not empty, please remove all the item before delete");
                    App.unblockUI($('.dgvUnplannedLoads'));
                } else {
                    $(".dgvUnplannedLoads").html(data);
                }
            }
        });
    }
</script>
<table class="table table-bordered table-fix loadunplannedload tbl-selected" data-height="200">
    <thead>
        <tr>
            <th>Status</th>
            <th>LoadCode</th>
            <th>Postcode</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr onclick="loadcreatorloaditem(@item.LoadID)" data-id="@item.LoadID">
                <td style="text-align: center">
                    @if (item.LoadStatusID == LoadStatus.UNPLANNED.StatusId())
                    {
                        <img src="/img/Load/Symbol-unplanned.png" alt="" />
                    }
                    else if (item.LoadStatusID == LoadStatus.REPLAN.StatusId())
                    {
                        <img src="/img/Load/Symbol-alert.png" alt="" />
                    }
                </td>
                <td>@item.LoadCode</td>
                <td>@item.Postcode</td>
            </tr>
        }
    </tbody>
</table>
